<template>
    <div class="filemessage-wrapper">
        <div class="filemessage-filetype">{{ fileType }}</div>
        <div class="filemessage-filename">
            {{ filename }}
        </div>
        <div @click="openurl" class="el-icon-download filemessage-download">

        </div>
    </div>
</template>

<script>
export default {
    name: "FileMessage",
    props: ['url', 'filename'],
    data(){
        return{
            fileType:'',
        }
    },
    methods: {
        openurl() {
            window.open(this.url, '_blank')
        }
    },
    mounted() {
        var index= this.filename.lastIndexOf(".");
//获取后缀
        var ext = this.filename.substr(index+1);
        this.fileType=ext
    }
}
</script>

<style scoped>
.filemessage-wrapper {
    position: relative;
    margin-top: 5px;
    width: 250px;
    background-color: #ffffff;

    padding: 8px 20px;
    border-radius: 5px;
    display: flex;
    align-items: center;
}

.filemessage-filetype {
    background-color: #ff7052;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 10px;
    font-size: 8px;
    color: white;
}

.filemessage-filename {
    margin-left: 10px;
    font-size: 15px;
    overflow: hidden;
    max-width: 160px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filemessage-download {
    position: absolute;
    right: 20px;
    font-size: 20px;
    transition: all ease-in-out 300ms;
    cursor: pointer;
}

.filemessage-download:hover {
    color: #6DBEF8;
}
</style>